home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_vim.idb / usr / freeware / share / vim / doc / syntax.txt.z / syntax.txt
Encoding:
Text File  |  1998-10-28  |  56.4 KB  |  1,378 lines

  1. *syntax.txt*    For Vim version 5.0.  Last modification: 1998 Feb 14
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Syntax highlighting        *syntax* *syntax-highlighting* *coloring*
  8.  
  9. Syntax highlighting enables the possibility to show parts of the text in
  10. another font or color.  Those parts can be specific keywords or text
  11. matching a pattern.  Vim doesn't parse the whole file (to keep it fast), so
  12. the highlighting has its limitations.  Lexical highlighting might be a
  13. better name, but everybody calls it syntax highlighting, so we'll stick with
  14. that.
  15.  
  16. Vim supports syntax highlighting on all terminals.  But since most ordinary
  17. terminals have very limited highlighting possibilities, it works best in the
  18. GUI version, gvim.
  19.  
  20. 1.  Quick start         |:syn-qstart|
  21. 2.  Syntax files     |:syn-files|
  22. 3.  Syntax file remarks     |:syn-file-remarks|
  23. 4.  Defining a syntax     |:syn-define|
  24. 5.  :syntax arguments     |:syn-arguments|
  25. 6.  Syntax patterns     |:syn-pattern|
  26. 7.  Synchronizing     |:syn-sync|
  27. 8.  Listing syntax items |:syntax|
  28. 9.  Highlight command     |:highlight|
  29. 10. Linking groups     |:highlight-link|
  30. 11. Cleaning up         |:syn-clear|
  31. 12. Highlighting tags     |tag-highlight|
  32. 13. Color xterms     |xterm-color|
  33.  
  34. {Vi does not have any of these commands}
  35.  
  36. The syntax highlighting is not available when the |+syntax| feature has been
  37. disabled at compile time.
  38.  
  39. ==============================================================================
  40. 1. Quick start                        *:syn-qstart*
  41.  
  42.                             *:syn-on*
  43. For a large number of common languages syntax files have been included.  To
  44. start using them, type this command:
  45. >  :syntax on
  46.  
  47. This will enable automatic syntax highlighting.  The type of highlighting will
  48. be selected using the file name extension, and sometimes using the first line
  49. of the file.
  50.  
  51. Include this command in your .vimrc if you always want syntax highlighting, or
  52. put it in your .gvimrc if you only want it in the GUI.  If you don't want it
  53. for B&W terminals, but you do want it for color terminals, put this in your
  54. .vimrc:
  55. >  if &t_Co > 1
  56. >    syntax on
  57. >  endif
  58.  
  59. What this command actually does, is executing the command
  60. >  source $VIM/syntax/syntax.vim
  61. If the VIM environment variable is not set, Vim will try to find
  62. the path in another way (see |$VIM|).  Normally this will work just fine.  If
  63. it doesn't, try setting the VIM environment variable to the directory where
  64. the Vim stuff is located.  For example, if your syntax files are in the
  65. "/usr/vim/5.0/syntax" directory, set $VIM to "/usr/vim/5.0".  You must do this
  66. in the shell, before starting Vim.
  67.  
  68.                             *:syn-default-override*
  69. You can override the default highlight settings, by issuing ":highlight"
  70. commands after sourcing "syntax.vim".  For example:
  71. >  syntax on
  72. >  highlight Constant gui=NONE guibg=grey95
  73.  
  74. This will change the GUI highlighting for the "Constant" group.  See
  75. |:highlight| about how to specify highlighting attributes.
  76.  
  77. If you are running in the GUI, you can get white text on a black background
  78. with:
  79. >  highlight Normal guibg=Black guifg=White
  80.  
  81. If you have a black background, use these commands to get better colors (see
  82. 'background'):
  83. >  set background=dark
  84. >  syntax on
  85.  
  86. NOTE: The syntax files on MS-DOS and Windows have lines that end in <CR><NL>.
  87. The files for Unix end in <NL>.  This means you should use the right type of
  88. file for your system.  Although on MS-DOS and Windows the right format is
  89. automatically selected if the 'fileformats' option is not empty.
  90.  
  91. To switch off the syntax highlighting:            *:syn-off*
  92. >  :syntax off
  93.  
  94. You can toggle the syntax on/off with this command
  95. >  :if has("syntax_items") | syntax off | else | syntax on | endif
  96.  
  97. To put this into a mapping, you can use:
  98. >  map <F7> :if has("syntax_items") <Bar> syntax off <Bar> else <Bar> syntax on <Bar> endif <CR>
  99. [using the |<>| notation, type this literally]
  100.  
  101. ==============================================================================
  102. 2. Syntax files                        *:syn-files*
  103.  
  104. The syntax and highlighting commands for one language are normally stored in
  105. a syntax file.  The name convention is: "{name}.vim".  Where {name} is the
  106. name of the language, or an abbreviation (to fit the name in 8.3 characters,
  107. which is always done, in case the file will be used on a DOS filesystem).
  108. Examples:
  109.     c.vim        perl.vim    java.vim    html.vim
  110.     cpp.vim        sh.vim        csh.vim
  111.  
  112. The syntax file can contain any Ex commands, just like a vimrc file.  But
  113. the idea is that only commands for a specific language are included.  When a
  114. language is a superset of another language, it may include the other one,
  115. for example, the cpp.vim file could include the c.vim file:
  116. >  :so $VIM/syntax/c.vim
  117.  
  118. The .vim files are normally loaded with an autocommand.  For example:
  119. >  :au BufNewFile,BufReadPost *.c,*.h source $VIM/syntax/c.vim
  120. >  :au BufNewFile,BufReadPost *.cpp source $VIM/syntax/cpp.vim
  121.  
  122.  
  123. MAKING YOUR OWN SYNTAX FILES                *mysyntaxfile*
  124.  
  125. When you create your own syntax files, and you want to have these
  126. automatically used with ":syntax on", do this:
  127.  
  128. 1. Create a file that contains the autocommands to load your syntax file when
  129.    the right file name or extension is detected.  To prevent loading two
  130.    syntax files (when the extension is used twice), first delete other
  131.    autocommands for the same extension.  You can also include ":highlight"
  132.    commands in this file, which override the normal highlighting (because the
  133.    file is sourced after setting the normal highlighting).  Example:
  134. >    augroup syntax
  135. >    au! BufNewFile,BufReadPost *.bat
  136. >    au  BufNewFile,BufReadPost *.bat  so ~/vim/batch.vim
  137. >    augroup END
  138. >    highlight Comment gui=bold
  139.    Let's assume you write this file in "~/vim/mysyntax.vim".
  140.  
  141. 2. In your .vimrc, set the "mysyntaxfile" variable to the file you just
  142.    created.  For example:
  143. >  :let mysyntaxfile = "~/vim/mysyntax.vim"
  144.  
  145. 3. If your file type can only be detected by inspecting the contents of the
  146.    file, create another file for doing this.  See $VIM/syntax/scripts.vim for
  147.    examples.  Let's assume you write this file in "~/vim/myscripts.vim".
  148.    Then set the "myscriptsfile" variable to this file name.  Example:
  149. >  :let myscriptsfile = "~/vim/myscripts.vim"
  150.    Note that this file is only used when no syntax file was loaded by the
  151.    autocommands, if the file type has not been detected by the file name or
  152.    extension.
  153.  
  154. Note that "mysyntaxfile" is sourced AFTER defining the default autocommands
  155. for the supplied syntax files, so you can override these with your own files.
  156. The "myscriptsfile" is loaded before the default checks for syntax files,
  157. which also means that your rules override the supplied rules.
  158.  
  159.  
  160. NAMING CONVENTIONS
  161.                             *group-name*
  162. To be able to allow each user to pick his favorite set of colors, there need
  163. to be preferred names for highlight groups that are common for many languages.
  164. These are the ones that are suggested to be used:
  165.  
  166.     *Comment    any comment
  167.  
  168.     *Constant    any constant
  169.      String        a string constant: "this is a string"
  170.      Character    a character constant: 'c', '\n'
  171.      Number        a number constant: 234, 0xff
  172.      Boolean    a boolean constant: TRUE, false
  173.      Float        a floating point constant: 2.3e10
  174.  
  175.     *Identifier    any variable name
  176.      Function    function name (also: methods for classes)
  177.  
  178.     *Statement    any statement
  179.      Conditional    if, then, else, endif, switch, etc.
  180.      Repeat        for, do, while, etc.
  181.      Label        case, default, etc.
  182.      Operator    "sizeof", "+", "*", etc.
  183.      Keyword    any other keyword
  184.      Exception    try, catch, throw
  185.  
  186.     *PreProc    generic Preprocessor
  187.      Include    preprocessor #include
  188.      Define        preprocessor #define
  189.      Macro        same as Define
  190.      PreCondit    preprocessor #if, #else, #endif, etc.
  191.  
  192.     *Type        int, long, char, etc.
  193.      StorageClass    static, register, volatile, etc.
  194.      Structure    struct, union, enum, etc.
  195.      Typedef    A typedef
  196.  
  197.     *Special    any special symbol
  198.      SpecialChar    special character in a constant
  199.      Tag        you can use CTRL-] on this
  200.      Delimiter    character that needs attention
  201.      SpecialComment    special things inside a comment
  202.      Debug        debugging statements
  203.  
  204.     *Error        any erroneous construct
  205.  
  206.     *Todo        anything that needs extra attention
  207.  
  208. The ones marked with * are the preferred groups, the other are minor groups.
  209. For the preferred groups, the "syntax.vim" file contains default highlighting.
  210. The minor groups are linked to the preferred groups, so they get the same
  211. highlighting.  You can override these defaults by giving ":highlight" commands
  212. after sourcing the "syntax.vim" file.
  213.  
  214. Note that highlight group names are not case sensitive.  "String" and "string"
  215. can be used for the same group.
  216.  
  217. The following names are reserved and cannot be used as a group name:
  218.     NONE   ALL   ALLBUT   contains   contained
  219.  
  220. ==============================================================================
  221. 3. Syntax file remarks                    *:syn-file-remarks*
  222.  
  223.                         *current_syntax-variable*
  224. The name of the syntax that has been loaded is stored in the "current_syntax"
  225. variable.  You can use this if you want to load other settings, depending on
  226. which syntax is active.  Example:
  227. >  :au BufReadPost * if current_syntax == "csh"
  228. >  :au BufReadPost *   do-some-things
  229. >  :au BufReadPost * endif
  230.  
  231.  
  232. 2HTML                        *2html.vim* *convert-to-HTML*
  233.  
  234. This is not a syntax file itself, but a script that converts the current
  235. window into HTML.  A new window is opened, in which the HTML file is built.
  236.     Warning: This is slow!
  237. The resulting file can be written where you want it.  You can then view it
  238. with any HTML viewer, such as Netscape.  The colors should be exactly the same
  239. as you see them in Vim.  From Netscape you can also print the file (in color)!
  240. This only works in the GUI version.  When 'tabstop' is not 8, the amount of
  241. white space will be wrong.
  242.  
  243.  
  244. HTML                            *html.vim*
  245.  
  246. The coloring scheme for tags in the html file works as follows
  247.  
  248. The  <> of opening tags are colored differently than the </> of a closing tag.
  249. This is on purpose! For opening tags the 'Function' color is used, while for
  250. closing tags the 'Type' color is used (See syntax.vim to check how those are
  251. defined for you)
  252.  
  253. Known tag names are colores the same way as statements in C.
  254. Unknown tag names are colored with the same color as the
  255. <> or </> respectively which makes it easy to spot errors
  256.  
  257. Note that the same is true for argument (or attribute names). Known
  258. attribute names are colored differently than unknown ones.
  259.  
  260. HTML comments are rather special (see an html reference document for the
  261. details), and the syntax coloring scheme will highlight all errors.
  262.  
  263. JavaScript embedded inside html documents is highlighted as 'Special'
  264. with statements, comments, strings and so on colored as in standard
  265. programming languages. Note that only JavaScript is currently supported,
  266. no other scripting language has been added yet.
  267.  
  268.  
  269. C                            *c.vim*
  270.  
  271. Most C highlighting is fixed.  There is one optional feature: highlighting
  272. strings and numbers inside a comment.  It can be enabled by adding this line
  273. to your vimrc:
  274.     let c_comment_strings=1
  275. To disable it again, use this:
  276.     unlet c_comment_strings
  277.  
  278.  
  279. JAVA                            *java.vim*
  280.  
  281. The java.vim syntax highlighting file offers several options:
  282.  
  283. In Java 1.0.2 it was never possible to have braces inside parens,
  284. so this was flagged as an error.  Since Java 1.1 this is possible (with
  285. anonymous classes), and therefore is no longer marked as an error. If you
  286. prefer the old way, put the following line into your vim startup file:
  287. >  let java_mark_braces_in_parens_as_errors=1
  288.  
  289. Function names are not highlighted, as the way to find functions depends on
  290. how you write java code.  To enable it anyway put the following line in your
  291. startup file:
  292. >  let java_highlight_functions=1
  293. This will only work if you either use two spaces for indentation or tabs.
  294. If you use another indentation style but would still want function
  295. declarations to be highlighted create your own definitions by changing the
  296. definitions in java.vim or by creating your own java.vim which includes
  297. the original one and then adds the code to highlight functions.
  298.  
  299. In java 1.1 the functions System.out.println() and System.err.println() should
  300. only be used for debugging. Therefor it is possible to highlight debugging
  301. statements differently. To do this you must add the following definition in
  302. your startup file:
  303. >  let java_highlight_debug=1
  304. The result will be that those statements are highlighted as 'Special'
  305. characters. If you prefer to have them highlighted differently you must define
  306. new highlightings for the following groups.:
  307.     Debug, DebugSpecial, DebugString, DebugBoolean, DebugType
  308. which are used for the statement itself, special characters used in debug
  309. strings, strings, boolean constants and types (this, super) respectively. I
  310. have opted to chose another background for those statements.
  311.  
  312. Javadoc is a program that takes special comments out of java program files and
  313. creates html pages. The standard configuration will highlight this html code
  314. similarly to html files (see |html.vim|). There are three differences:
  315.   1. The title (all characters up to the first '.' which is followed by
  316.      some white space or to the first '@') is colored differently (to change
  317.      the color change the group CommentTitle).
  318.   2. The text is colored as 'Comment'.
  319.   3. HTML comments are colored as 'Special'
  320. To turn this feature off add the following line to your startup file:
  321. >  let java_ignore_javadoc=1
  322.  
  323.  
  324. SH                            *sh.vim*
  325.  
  326. This covers the "normal" Unix sh, bash and the korn shell.  If you're working
  327. on a system where bash is called sh, you will benefit to define the vim
  328. variable 'bash_is_sh' in your '.vimrc' file:
  329. >  let bash_is_sh = 1
  330.  
  331. To choose between the two ways to treat single-quotes inside a pair of
  332. double-quotes, I have introduced a Vim variable "highlight_balanced_quotes".
  333. By default (ie by not declaring this variable) single quotes can be used
  334. inside double quotes, and are not highlighted.  If you prefer balanced single
  335. quotes as I do you just make the statement in your .vimrc file:
  336. >  let highlight_balanced_quotes = 1
  337.  
  338. Similar I have introduced another vim variable "highlight_function_name" to be
  339. used to enable/disable highlighting of the function-name in function
  340. declaration.  Default is not to highlight the function name.  If you want to
  341. highlight functions names, include this in your .vimrc file:
  342. >  let highlight_function_name = 1
  343.  
  344. ==============================================================================
  345. 4. Defining a syntax                    *:syn-define*
  346.  
  347. Vim understands three types of syntax items:
  348. 1. A keyword.  It can only contain keyword characters, according to the
  349.    'iskeyword' option.  It cannot contain other syntax items.  It will only
  350.    be recognized when it is a complete match (there are no keyword
  351.    characters before or after the match).  "if" would match in "if(a=b)",
  352.    but not in "ifdef x".
  353. 2. A match.  This is a match with a single regexp pattern.  It must be within
  354.    one line.
  355. 3. A region.  This starts at a match of the start regexp pattern and
  356.    ends with a match with the end regexp pattern.  A skip regexp pattern can
  357.    be used to avoid matching the end pattern.
  358.  
  359. Several syntax ITEMs can be put into one syntax GROUP.  For a syntax group
  360. you can give highlighting attributes.  For example, you could have an item
  361. to define a "/* .. */" comment and another one that defines a "// .." comment,
  362. and put them both in the "Comment" group.  You can then specify that a
  363. "Comment" will be in bold font and have a blue color.  You are free to make
  364. one highlight group for one syntax item, or put all items into one group.
  365. This depends on how you want to specify your highlighting attributes.  Putting
  366. each item in its own group results in having to specify the highlighting
  367. for a lot of groups.
  368.  
  369. Note that a syntax group and a highlight group are similar.  For a highlight
  370. group you will have given highlight attributes.  These attributes will be used
  371. for the syntax group with the same name.
  372.  
  373. In case more than one item matches at the same position, the one that was
  374. defined LAST wins.  Thus you can override previously defined syntax items by
  375. using an item that matches the same text.  But a keyword always goes before a
  376. match or region.  And a keyword with matching case always goes before a
  377. keyword with ignoring case.
  378.  
  379.  
  380. DEFINING CASE                        *:syn-case*
  381.  
  382. :syntax case [match|ignore]
  383.     This defines if the following ":syntax" commands will work with
  384.     matching case, when using "match", or with ignoring case, when using
  385.     "ignore".  Note that any items before this are not affected, and all
  386.     items until the next ":syntax case" command are affected.
  387.  
  388.  
  389. DEFINING KEYWORDS                    *:syn-keyword*
  390.  
  391. :syntax keyword {group-name} [{options}] {keyword} .. [{options}]
  392.  
  393.     This defines a number of keywords.
  394.  
  395.     {group-name}    Is a syntax group name such as "Comment".
  396.     [{options}]    See |:syn-arguments| below.
  397.     {keyword} ..    Is a list of keywords which are part of this group.
  398.  
  399.     Example:
  400. >  :syntax keyword   Type   int long char
  401.  
  402.     The {options} can be given anywhere in the line.  They will apply to
  403.     all keywords given, also for options that come after a keyword.
  404.     These examples do exactly the same:
  405. >  :syntax keyword   Type   contained int long char
  406. >  :syntax keyword   Type   int long contained char
  407. >  :syntax keyword   Type   int long char contained
  408.  
  409.     When you have a keyword with an optional tail, like Ex commands in
  410.     Vim, you can put the optional characters inside [], to define all the
  411.     variations at once:
  412. >  :syntax keyword   VimCommand   ab[breviate] n[ext]
  413.  
  414.     A keyword always has higher priority than a match or region, the
  415.     keyword is used if more than one item matches.  Keywords do not nest
  416.     and a keyword can't contain anything else.
  417.  
  418.     Note that when you have a keyword that is the same as an option (even
  419.     one that isn't allowed here), you can not use it.  Use a match
  420.     instead.
  421.  
  422.         The maximum length of a keyword is 80 characters.
  423.  
  424.     The same keyword can be defined multiple times, when its containment
  425.     differs.  For example, you can define the keyword once not contained
  426.     and use one highlight group, and once contained, and use a different
  427.     highlight group. Example:
  428. >  :syn keyword vimCommand tag
  429. >  :syn keyword vimSetting contained tag
  430.     When finding "tag" outside of any syntax item, the "vimCommand"
  431.     highlight group is used.  When finding "tag" in a syntax item that
  432.     contains "vimSetting", the "vimSetting" group is used.
  433.  
  434.  
  435. DEFINING MATCHES                    *:syn-match*
  436.  
  437. :syntax match {group-name} [{options}] {pattern} [{options}]
  438.  
  439.     This defines one match.
  440.  
  441.     {group-name}        A syntax group name such as "Comment".
  442.     [{options}]        See |:syn-arguments| below.
  443.     {pattern}        The search pattern that defines the match.
  444.                 See |:syn-pattern| below.
  445.  
  446.     Example (match a character constant):
  447. >  :syntax match Character /'.'/s+1e-1
  448.  
  449.  
  450. DEFINING REGIONS    *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
  451.  
  452. :syntax region {group-name} [{options}]
  453.         [matchgroup={group_name}]
  454.         [keepend]
  455.         start={start_pattern} ..
  456.         [skip={skip_pattern}]
  457.         end={end_pattern} ..
  458.         [{options}]
  459.  
  460.     This defines one region.  It may span several lines.
  461.  
  462.     {group-name}        A syntax group name such as "Comment".
  463.     [{options}]        See |:syn-arguments| below.
  464.     [matchgroup={group-name}]  The syntax group to use for the following
  465.                 start or end pattern matches only.  Not used
  466.                 for the text in between the matched start and
  467.                 end patterns.  Use NONE to reset to not using
  468.                 a different group for the start or end match.
  469.                 See |:syn-matchgroup|.
  470.     keepend            Don't allow contained matches to go past a
  471.                 match with the end pattern.  See
  472.                 |:syn-keepend|.
  473.     start={start_pattern}    The search pattern that defines the start of
  474.                 the region.  See |:syn-pattern| below.
  475.     skip={skip_pattern}    The search pattern that defines text inside
  476.                 the region where not to look for the end
  477.                 pattern.  See |:syn-pattern| below.
  478.     end={end_pattern}    The search pattern that defines the end of
  479.                 the region.  See |:syn-pattern| below.
  480.  
  481.     Example:
  482. >  :syntax region String   start=+"+  skip=+\\"+  end=+"+
  483.  
  484.     The start/skip/end patterns and the options can be given in any order.
  485.     There can be zero or one skip pattern.  There must be one or more
  486.     start and end patterns.  This means that you can omit the skip
  487.     pattern, but you must give at least one start and one end pattern.  It
  488.     is allowed to have white space before and after the equal sign
  489.     (although it mostly looks better without white space).
  490.  
  491.     When more than one start pattern is given, a match with one of these
  492.     is sufficient.  This means there is an OR relation between the start
  493.     patterns.  The first one that matches is used.  The same is true for
  494.     the end patterns.
  495.  
  496.     The search for the end pattern starts at the start of the region.
  497.     This implies that it can also match inside the start pattern!
  498.  
  499.     Note: The decision to start a region is only based on a matching start
  500.     pattern.  There is no check for a matching end pattern.  This does NOT
  501.     work:
  502.         :syn region First  start="("  end="."
  503.         :syn region Second start="("  end=";"
  504.     The Second always matches before the First (last defined pattern has
  505.     higher priority).  The Second region then continues until the next
  506.     ';', no matter if there is a '.' before it.
  507.  
  508.                             *:syn-keepend*
  509.     By default, a contained match can obscure a match for the end pattern.
  510.     This is useful for nesting.  For example, a region that starts with
  511.     "{" and ends with "}", can contain another region.  An encountered "}"
  512.     will then end the contained region, but not the outer region:
  513.         {        starts outer "{}" region
  514.         {    starts contained "{}" region
  515.         }    ends contained "{}" region
  516.         }        ends outer "{} region
  517.     If you don't want this, the "keepend" argument will make the matching
  518.     of an end pattern of the outer region also end any contained item.
  519.     This makes it impossible to nest the same region, but allows for
  520.     contained items to highlight parts of the end pattern, without causing
  521.     that to skip the match with the end pattern.  Example:
  522. >  :syn match  VimComment +"[^"]\+$+
  523. >  :syn region VimCommand start="set" end="$" contains VimComment keepend
  524.     The "keepend" makes the VimCommand always end at the end of the line,
  525.     even though the contained VimComment includes a match with the <EOL>.
  526.  
  527.     When "keepend" is not used, a match with an end pattern is retried
  528.     after each contained match.  When "keepend" is included, the first
  529.     encountered match with an end pattern is used, truncating any
  530.     contained matches.
  531.  
  532.                             *:syn-matchgroup*
  533.     "matchgroup" can be used to highlight the start and/or end pattern
  534.     differently than the body of the region.  Example:
  535. >  :syntax region String matchgroup=Quote start=+"+  skip=+\\"+  end=+"+
  536.     This will highlight the quotes with the "Quote" group, and the text in
  537.     between with the "String" group.
  538.     The "matchgroup" is used for all start and end patterns that follow,
  539.     until the next "matchgroup".  Use "matchgroup=NONE" to go back to not
  540.     using a matchgroup.
  541.  
  542.     It is not possible to have a contained match in a start or end pattern
  543.     that is highlighted with "matchgroup".
  544.     When using "transparent", it does not apply to a start or end pattern
  545.     that is highlighted with "matchgroup".
  546.  
  547. ==============================================================================
  548. 5. :syntax arguments                    *:syn-arguments*
  549.  
  550. The :syntax commands that define syntax items take a number of arguments.
  551. The common ones are explained here.  The arguments may be given in any order
  552. and may be mixed with patterns.
  553.  
  554. Not all commands accept all arguments.  This table shows which arguments
  555. can be used for each command:
  556.  
  557.          contained  nextgroup  skip*   transparent  contains  oneline ~
  558. :syntax keyword        yes           yes    yes        -           -     -
  559. :syntax match        yes           yes    yes       yes          yes     -
  560. :syntax region        yes           yes    yes       yes          yes    yes
  561.  
  562.  
  563. contained                         *:syn-contained*
  564.  
  565. When the "contained" argument is given, this item will not be recognized at
  566. the top level, but only when it is mentioned in the "contains" field of
  567. another match.  Example:
  568. >   :syntax keyword Todo    TODO    contained
  569. >   :syntax match   Comment "//.*"  contains=Todo
  570.  
  571.  
  572. transparent                        *:syn-transparent*
  573.  
  574. If the "transparent" argument is given, this item will not be highlighted
  575. itself, but will take the highlighting of the item it is contained in.  This
  576. is useful for syntax items that don't need any highlighting but are used
  577. only to skip over a part of the text.  The same groups as the item it is
  578. contained in are used, unless a "contains" argument is given too.
  579.  
  580.  
  581. oneline                            *:syn-oneline*
  582.  
  583. The "oneline" argument indicates that the region does not cross a line
  584. boundary.  It must match completely in the current line.  However, when the
  585. region has a contained item that does cross a line boundary, it continues on
  586. the next line anyway.  A contained item can be used to recognize a line
  587. continuation pattern.
  588.  
  589.  
  590. contains={groupname},..                    *:syn-contains*
  591.  
  592. The "contains" argument is followed by a list of syntax group names.  These
  593. groups will be allowed to begin inside the item (they may extend past the
  594. containing group's end).  This allows for recursive nesting of matches and
  595. regions.  If there is no "contains" argument, no groups will be contained in
  596. this item.  The group names do not need to be defined before they can be used
  597. here.
  598.  
  599. contains=ALL
  600.         If the only item in the contains list is "ALL", then all
  601.         groups will be accepted inside the item.
  602.  
  603. contains=ALLBUT,{group-name},..
  604.         If the first item in the contains list is "ALLBUT", then all
  605.         groups will be accepted inside the item, except the ones that
  606.         are listed, and the "contained" items.  Example:
  607. >  :syntax region Block start="{" end="}" ... contains=ALLBUT,Function
  608.  
  609. The {group-name} in the "contains" list can be a pattern.  All group names
  610. that match the pattern will be included (or excluded, if "ALLBUT" is used).
  611. The pattern cannot contain white space or a ','.  Example:
  612. >  ... contains=Comment.*,Keyw[0-3]
  613.  
  614.  
  615. nextgroup={groupname},..                *:syn-nextgroup*
  616.  
  617. The "nextgroup" argument is followed by a list of syntax group names,
  618. separated by commas (just like with "contains", so you can also use patterns).
  619.  
  620. If the "nextgroup" argument is given, the mentioned syntax groups will be
  621. tried for a match, after the match or region ends.  If none of the groups have
  622. a match, highlighting continues normally.  If there is a match, this group
  623. will used, even when it is not mentioned in the "contains" field of the
  624. current group.  This is like giving the mentioned group priority over all
  625. other groups.  Example:
  626. >   :syntax match  ccFoobar  "Foo.\{-}Bar"  contains=ccFoo
  627. >   :syntax match  ccFoo     "Foo"        contained nextgroup=ccFiller
  628. >   :syntax region ccFiller  start="."  matchgroup=ccBar  end="Bar"  contained
  629.  
  630. This will highlight "Foo" and "Bar" differently, and only when there is a
  631. "Bar" after "Foo".  In the text line below, "f" shows where ccFoo is used for
  632. highlighting, and "bbb" where ccBar is used.
  633.  
  634. >   Foo asdfasd Bar asdf Foo asdf Bar asdf
  635. >   fff        bbb      fff      bbb
  636.  
  637. Note the use of ".\{-}" to skip as little as possible until the next Bar.
  638. when ".*" would be used, the "asdf" in between "Bar" and "Foo" would be
  639. highlighted according to the "ccFoobar" group, because the ccFooBar match
  640. would include the first "Foo" and the last "Bar" in the line (see |pattern|).
  641.  
  642.  
  643. skipwhite                        *:syn-skipwhite*
  644. skipnl                            *:syn-skipnl*
  645. skipempty                        *:syn-skipempty*
  646.  
  647. These arguments are only used in combination with "nextgroup".  They can be
  648. used to allow the next group to match after skipping some text:
  649.     skipwhite    skip over space and Tab characters
  650.     skipnl        skip over the end of a line
  651.     skipempty    skip over empty lines (implies a "skipnl")
  652.  
  653. When "skipwhite" is present, the white space is only skipped if there is no
  654. next group that matches the white space.
  655.  
  656. When "skipnl" is present, the match with nextgroup may be found in the next
  657. line.  This only happens when the current item ends at the end of the current
  658. line!  When "skipnl" is not present, the nextgroup will only be found after
  659. the current item in the same line.
  660.  
  661. When skipping text while looking for a next group, the matches for other
  662. groups are ignored.  Only when no next group matches, other items are tried
  663. for a match again.  This means that matching a next group and skipping white
  664. space and <EOL>s has a higher priority than other items.
  665.  
  666. Example:
  667. >  syn match ifstart "if.*"     nextgroup=ifline skipwhite skipempty
  668. >  syn match ifline  "endif"    contained
  669. >  syn match ifline  "[^ \t].*" nextgroup=ifline skipwhite skipempty contained
  670. Note that the last match, which matches any non-white text, is put last,
  671. otherwise the "endif" of the indent would never match, because the "[^ \t].*"
  672. would match first.
  673. Note that this example doesn't work for nested "if"s.  You need to add
  674. "contains" arguments to make that work (omitted for simplicity of the
  675. example).
  676.  
  677. ==============================================================================
  678. 6. Syntax patterns                    *:syn-pattern*
  679.  
  680. In the syntax commands, a pattern must be surrounded by two identical
  681. characters.  This is like it works for the ":s" command.  The most common to
  682. use is the double quote.  But if the pattern contains a double quote, you can
  683. use another character that is not used in the pattern.  Examples:
  684. >  :syntax region Comment  start="/\*"  end="\*/"
  685. >  :syntax region String   start=+"+    end=+"+   skip=+\\"+
  686.  
  687. See |pattern| for the explanation of what a pattern is.  Syntax patterns are
  688. always interpreted like the 'magic' options is set, no matter what the actual
  689. value of 'magic' is.  And the patterns are interpreted like the 'l' flag is
  690. not included in 'cpoptions'.  This was done to make syntax files portable and
  691. independent of 'compatible' and 'magic' settings.
  692.  
  693. Try to avoid patterns that can match an empty string, such as "[a-z]*".
  694. This slows down the highlighting a lot, because it matches everywhere.
  695.  
  696. The pattern can be followed by a character offset.  This can be used to
  697. change the highlighted part, and to change the text area included in the
  698. match or region (which only matters when trying to match other items).  Both
  699. are relative to the matched pattern.  The character offset for a skip
  700. pattern can be used to tell where to continue looking for an end pattern.
  701.  
  702. The offset takes the form of "{what}={offset}"
  703. The {what} can be one of six strings:
  704.  
  705. ms    Match Start    offset for the start of the matched text
  706. me    Match End    offset for the end of the matched text
  707. hs    Highlight Start    offset for where the highlighting starts
  708. he    Highlight End    offset for where the highlighting ends
  709. rs    Region Start    offset for where the body of a region starts
  710. re    Region End    offset for where the body of a region ends
  711. lc    Leading Context    offset past "leading context" of pattern
  712.  
  713. The {offset} can be:
  714.  
  715. s    start of the matched pattern
  716. s+{nr}    start of the matched pattern plus {nr} chars to the right
  717. s-{nr}    start of the matched pattern plus {nr} chars to the left
  718. e    end of the matched pattern
  719. e+{nr}    end of the matched pattern plus {nr} chars to the right
  720. e-{nr}    end of the matched pattern plus {nr} chars to the left
  721. {nr}    (for "lc" only): start matching {nr} chars to the left
  722.  
  723. Examples: "ms=s+1", "hs=e-2", "lc=3".
  724.  
  725. Although all offsets are accepted after any pattern, they are not always
  726. meaningful.  This table shows which offsets are actually used:
  727.  
  728.             ms   me   hs   he   rs   re      lc ~
  729. match item        yes  yes  yes  yes  -    -    yes
  730. region item start   yes  -    yes  -    yes  -    yes
  731. region item skip    -    yes  -    -    -    -    -
  732. region item end     -    yes  -    yes  -    yes  -
  733.  
  734. Offsets can be concatenated, with a ',' in between.  Example:
  735. >  syn match String  /".*"/hs=s+1,he=e-1
  736.  
  737.     some "string" text
  738.       ^^^^^^        highlighted
  739.  
  740. Notes:
  741. - There must be no white space between the pattern and the character
  742.   offset(s).
  743. - The highlighted area will never be outside of the matched text.
  744. - A negative offset for an end pattern may not always work, because the end
  745.   pattern may be detected when the highlighting should already have stopped.
  746.  
  747. Example (match a comment but don't highlight the /* and */):
  748. >  :syntax region Comment start="/\*"hs=e+1 end="\*/"he=s-1
  749.  
  750.     /* this is a comment */
  751.       ^^^^^^^^^^^^^^^^^^^     highlighted
  752.  
  753. A more complicated Example:
  754. >  :syn region Exa matchgroup=Foo start="foo"hs=s+2,rs=e+2 matchgroup=Bar end="bar"me=e-1,he=e-1,re=s-1
  755.  
  756.      abcfoostringbarabc
  757.         mmmmmmmmmmm        match
  758.           ssrrrreee        highlight start/region/end ("Foo", "Exa" and "Bar")
  759.  
  760. Leading context            *:syn-lc* *:syn-leading* *:syn-context*
  761.  
  762. The "lc" offset specifies leading context -- a part of the pattern that must
  763. be present, but is not considered part of the match.  An offset of "lc=n" will
  764. cause Vim to step back n columns before attempting the pattern match, allowing
  765. characters which have already been matched in previous patterns to also be
  766. used as leading context for this match.  This can be used, for instance, to
  767. specify that an "escaping" character must not precede the match:
  768.  
  769. >  :syn match ZNoBackslash "[^\\]z"ms=s+1
  770. >  :syn match WNoBackslash "[^\\]w"lc=1
  771. >  :syn match Underline "_\+"
  772.  
  773.       ___zzzz ___wwww
  774.       ^^^     ^^^      matches Underline
  775.           ^ ^      matches ZNoBackslash
  776.              ^^^^ matches WNoBackslash
  777.  
  778. The "ms" offset is automatically set to the same value as the "lc" offset,
  779. unless you set "ms" explicitly.
  780.  
  781. ==============================================================================
  782. 7. Synchronizing                    *:syn-sync*
  783.  
  784. Vim wants to be able to start redrawing in any position in the document.  To
  785. make this possible it needs to know the syntax item at the position where
  786. redrawing starts.
  787.  
  788. :syntax sync [ccomment [group-name] | minlines={N} | ...]
  789.  
  790. There are three ways to synchronize:
  791. 1. Based on C-style comments.  Vim understands how C-comments work and can
  792.    figure out if the current line starts inside or outside a comment.
  793. 2. Jumping back a certain number of lines and start parsing there.
  794. 3. Searching backwards in the text for a pattern to sync on.
  795.  
  796. For all three methods, the line range where the parsing can start is limited
  797. by "minlines" and "maxlines".
  798.  
  799. If the "minlines={N}" argument is given, the parsing always starts at least
  800. that many lines backwards.  This can be used if the parsing may take a few
  801. lines before it's correct, or when it's not possible to use syncing.
  802.  
  803. If the "maxlines={N}" argument is given, the number of lines that are searched
  804. for a comment or syncing pattern is restricted to N lines backwards (after
  805. adding "minlines".  This is useful if you have few things to sync on and a
  806. slow machine.  Example:
  807. >  :syntax sync ccomment maxlines=500
  808.  
  809.  
  810. First syncing method:
  811.  
  812. For the first method, only the "ccomment" argument needs to be given.
  813. Example:
  814. >  :syntax sync ccomment
  815.  
  816. When Vim finds that the line where displaying starts is inside a C-style
  817. comment, the first region syntax item with the group-name "Comment" will be
  818. used.  This requires that there is a region with the group-name "Comment"!
  819. An alternate group name can be specified, for example:
  820. >  :syntax sync ccomment javaComment
  821.  
  822. The "maxlines" argument can be used to restrict the search to a number of
  823. lines.  The "minlines" argument can be used to at least start a number of
  824. lines back (e.g., for when there is some construct that only takes a few
  825. lines, but it hard to sync on).
  826.  
  827. Note: Syncing on a C comment doesn't work properly when strings are used
  828. that cross al line and contain a "*/".  Since letting strings cross a line
  829. is a bad programming habit (many compilers give a warning message), and the
  830. chance of a "*/" appearing inside a comment is very small, this restriction
  831. is hardly ever noticed.
  832.  
  833.  
  834. Second syncing method:
  835.  
  836. For the second method, only the "lines={N}" argument needs to be given.  Vim
  837. will subtract {N} from the line number and start parsing there.  This means
  838. {N} extra lines need to be parsed, which makes this method a bit slower.
  839. Example:
  840. >  :syntax sync lines=50
  841.  
  842. "lines" and "minlines" are equivalent.
  843.  
  844.  
  845. Third syncing method:
  846.  
  847. The idea is to synchronize on the end of a few specific regions, called a
  848. sync pattern.  Only regions can cross lines, so when we find the end of some
  849. region, we might be able to know in which syntax item we are.  The search
  850. starts in the line just above the one where redrawing starts.  From there
  851. the search continues backwards in the file.
  852.  
  853. This works just like the non-syncing syntax ltems.  You can use contained
  854. matches, nextgroup, etc.  But there are a few differences:
  855. - Keywords cannot be used.
  856. - The syntax items with the "sync" keyword form a completely separated group
  857.   of syntax items.  You can't mix syncing groups and non-syncing groups.
  858. - The matching works backwards in the buffer (line by line), instead of
  859.   forwards.
  860. - A line continuation pattern can be given.  It is used to decide which group
  861.   of lines need to be searched like they were one line.  This means that the
  862.   search for a match with the specified items starts in the first of the
  863.   consecutive that contain the continuation pattern.
  864. - When using "nextgroup" or "contains", this only works within one line (or
  865.   group of continuated lines).
  866. - When a match with a sync pattern is found, the rest of the line (or group of
  867.   continuated lines) is searched for another match.  The last match is used.
  868.   This is used when a line can contain both the start end the end of a region
  869.   (e.g., in a C-comment like /* this */, the last "*/" is used).
  870.  
  871. There are two ways how a match with a sync pattern can be used:
  872. 1. Parsing for highlighting starts where redrawing starts (and where the
  873.    search for the sync pattern started).  The syntax group that is expected
  874.    to be valid there must be specified.  This works well when the regions
  875.    that cross lines cannot contain other regions.
  876. 2. Parsing for highlighting continues just after the match.  The syntax group
  877.    that is expected to be present just after the match must be specified.
  878.    This can be used when the previous method doesn't work well.  It's much
  879.    slower, because more text needs to be parsed.
  880. Both types of sync patterns can be used at the same time.
  881.  
  882. Besides the sync patterns, other matches and regions can be specified, to
  883. avoid finding unwanted matches.
  884.  
  885. [The reason that the sync patterns are given separately, is that mostly the
  886. search for the sync point can be much simpler than figuring out the
  887. highlighting.  The reduced number of patterns means it will go (much)
  888. faster.]
  889.  
  890.     :syntax sync match {group-name} grouphere {sync-group-name} ..
  891.  
  892.     Define a match that is used for syncing.  {sync-group-name} is the
  893.     name of a syntax group that follows just after the match.  Parsing
  894.     of the text for highlighting starts just after the match.  A region
  895.     must exist for this sync-group-name.  The first one defined will be
  896.     used.  "NONE" can be used for when there is no syntax group after the
  897.     match.
  898.  
  899.     :syntax sync match {group-name} groupthere {sync-group-name} ..
  900.  
  901.     Like "grouphere", but {sync-group-name} is the name of a syntax
  902.     group that is to be used at the start of the line where searching
  903.     for the sync point started.  The text between the match and the
  904.     start of the sync pattern searching is assumed not to change the
  905.     syntax highlighting.  For example, in C you could search backwards for
  906.     "/*" and "*/".  If "/*" is found first, you know that you are inside a
  907.     comment, so the "groupthere" is "cComment".  If "*/" is found first,
  908.     you know that you are not in a comment, so the "groupthere" is "NONE".
  909.     (in practice it's a bit more complicated, because the "*/" and "*/"
  910.     could appear inside a string.  That's left as an exercise to the
  911.     reader...).
  912.  
  913.     :syntax sync match ..
  914.     :syntax sync region ..
  915.  
  916.     Without a "groupthere" argument.  Define a region or match that is
  917.     skipped while searching for a sync point.
  918.  
  919.     :syntax sync linecont {pattern}
  920.  
  921.     When {pattern} matches in a line, it is considered to continue in
  922.     the next line.  This means that the search for a sync point will
  923.     consider the lines to be concatenated.
  924.  
  925. If the "maxlines={N}" argument is given too, the number of lines that are
  926. searched for a match is restricted to N.  This is useful if you have very
  927. few things to sync on and a slow machine.  Example:
  928. >  :syntax sync maxlines=100
  929.  
  930. You can clear all sync settings with:
  931. >  :syntax sync clear
  932.  
  933. You can clear specific sync patterns with:
  934. >  :syntax sync clear {group-name} ..
  935.  
  936. ==============================================================================
  937. 8. Listing syntax items                    *:syntax* *:sy* *:syn*
  938.  
  939. This commands lists all the syntax items:
  940.  
  941.     :syntax [list]
  942.  
  943. To show the syntax items for one syntax group:
  944.  
  945.     :syntax list {group-name}
  946.  
  947. See above for other arguments for the ":syntax" command.
  948.  
  949. Note that the ":syntax" command can be abbreviated to ":sy", although ":syn"
  950. is mostly used, because it looks better.
  951.  
  952. ==============================================================================
  953. 9. Highlight command                    *:highlight*
  954.  
  955. There are two types of highlight groups:
  956. - The ones used for specific languages.  For these the name starts with the
  957.   name of the language.  Many of these don't have any attributes, but are
  958.   linked to a group of the second type.
  959. - The ones used for all languages.  These are also used for the 'highlight'
  960.   option.
  961.  
  962. :highlight        List all the current highlight groups that have
  963.             attributes set.
  964.  
  965. :highlight {group-name}
  966.             List one highlight group.
  967.  
  968. :highlight clear {group-name}
  969. :highlight {group-name} NONE
  970.             Disable the highlighting for one highlight group.
  971.  
  972. :highlight {group-name} {key}={arg} ..
  973.             Add a highlight group, or change the highlighting for
  974.             an existing group.  See below for the arguments
  975.             |highlight-args|.
  976.  
  977. Normally a highlight group is added once, in the *.vim file.  This sets
  978. the default values for the highlighting.  After that, you can use additional
  979. highlight commands to change the arguments that you want to set to
  980. non-default values.  The value "NONE" can be used to switch the value off or
  981. go back to the default value.
  982.  
  983. Example.  The syntax.vim file contains this line:
  984. >  hi Comment    term=bold ctermfg=Cyan guifg=#80a0ff
  985.  
  986. You can change this by giving another ":highlight: command:
  987. >  hi Comment    gui=bold
  988.  
  989. Note that all settings that are not included remain the same, only the
  990. specified field is used, and settings are merged with previous ones.  So, the
  991. result is like this single command has been used:
  992. >  hi Comment    term=bold ctermfg=Cyan guifg=#80a0ff gui=bold
  993.  
  994.                         *highlight-args*
  995. There are three types of terminals for highlighting:
  996. term    a normal terminal (vt100, xterm)
  997. cterm    a color terminal (MS-DOS console, color-xterm, these have the "Co"
  998.     termcap entry)
  999. gui    the GUI
  1000.  
  1001. For each type the highlighting can be given.  This makes it possible to use
  1002. the same syntax file on all terminals, and use the optimal highlighting.
  1003.  
  1004. 1. highlight arguments for normal terminals
  1005.  
  1006. term={attr-list}                *attr-list* *highlight-term*
  1007.     attr-list is a comma separated list (without spaces) of the
  1008.     following items (in any order):
  1009.         bold
  1010.         underline
  1011.         reverse
  1012.         inverse        same as reverse
  1013.         italic
  1014.         standout
  1015.         NONE        no attributes used (used to reset it)
  1016.  
  1017.     Note that "bold" can be used here and by using a bold font.  They
  1018.     have the same effect.
  1019.  
  1020. start={term-list}                *highlight-start*
  1021. stop={term-list}                *term-list* *highlight-stop*
  1022.     These lists of terminal codes can be used to get
  1023.     non-standard attributes on a terminal.
  1024.  
  1025.     The escape sequence specified with the "start" argument
  1026.     is written before the characters in the highlighted
  1027.     area.  It can be anything that you want to send to the
  1028.     terminal to highlight this area.  The escape sequence
  1029.     specified with the "stop" argument is written after the
  1030.     highlighted area.  This should undo the "start" argument.
  1031.     Otherwise the screen will look messed up.
  1032.  
  1033.     The {term-list} can have two forms:
  1034.  
  1035.     1. A string with escape sequences.
  1036.        This is any string of characters, except that it can't start with
  1037.        "t_" and blanks are not allowed.  The <> notation is recognized
  1038.        here, so you can use things like "<Esc>" and "<Space>".  Example:
  1039.         start=<Esc>[27h;<Esc>[<Space>r;
  1040.  
  1041.     2. A list of terminal codes.
  1042.        Each terminal code has the form "t_xx", where "xx" is the name of
  1043.        the termcap entry.  The codes have to be separated with commas.
  1044.        White space is not allowed.  Example:
  1045.         start=t_C1,t_BL
  1046.        The terminal codes must exist for this to work.
  1047.  
  1048.  
  1049. 2. highlight arguments for color terminals
  1050.  
  1051. cterm={attr-list}                    *highlight-cterm*
  1052.     See above for the description of {attr-list} |attr-list|.
  1053.     The "cterm" argument is likely to be different from "term", when
  1054.     colors are used.  For example, in a normal terminal comments could
  1055.     be underlined, in a color terminal they can be made Blue.
  1056.     Note: Many terminals (e.g., DOS console) can't mix these attributes
  1057.     with coloring.  Use only one of "cterm=" OR "ctermfg=" OR "ctermbg=".
  1058.  
  1059. ctermfg={color-nr}                    *highlight-ctermfg*
  1060. ctermbg={color-nr}                    *highlight-ctermbg*
  1061.     The {color-nr} argument is a color number.  Its range is zero to
  1062.     (not including) the number given by the termcap entry "Co".
  1063.     The actual color with this number depends on the type of terminal
  1064.     and its settings.  Sometimes the color also depends on the settings of
  1065.     "cterm".  For example, on some systems "cterm=bold ctermfg=3" gives
  1066.     another color, on others you just get color 3.
  1067.  
  1068.     For an xterm this depends on your resources, and is a bit
  1069.     unpredictable.  See your xterm documentation for the defaults.  The
  1070.     colors for a color-xterm can be changed from the .Xdefaults file.
  1071.     Unfortunately this means that it's not possible to get the same colors
  1072.     for each user.  See |xterm-color| for info about color xterms.
  1073.  
  1074.     The MSDOS standard colors are fixed (in a console window), so these
  1075.     have been used for the names.  But the meaning of color names in X11
  1076.     are fixed, so these color settings have been used, to make the
  1077.     highlighting settings portable (complicated, isn't it?).  The
  1078.     following names are recognized, with the color number used:
  1079.  
  1080.         NR-16   NR-8    COLOR NAME ~
  1081.                             *cterm-colors*
  1082.         0        0        Black
  1083.         1        4        DarkBlue
  1084.         2       2        DarkGreen
  1085.         3       6        DarkCyan
  1086.         4       1        DarkRed
  1087.         5       5        DarkMagenta
  1088.         6       3        Brown
  1089.         7       7        LightGray, LightGrey, Gray, Grey
  1090.         8        0*        DarkGray, DarkGrey
  1091.         9        4*        Blue, LightBlue
  1092.         10        2*        Green, LightGreen
  1093.         11        6*        Cyan, LightCyan
  1094.         12        1*        Red, LightRed
  1095.         13        5*        Magenta, LightMagenta
  1096.         14        3*        Yellow
  1097.         15        7*        White
  1098.  
  1099.     The number under "NR-16" is used for 16-color terminals ('t_Co'
  1100.     greater than or equal to 16).  The number under "NR-8" is used for
  1101.     8-color terminals ('t_Co' less than 16).  The '*' indicates that the
  1102.     bold attribute is set for ctermfg.  In many 8-color terminals (e.g.,
  1103.     "linux"), this causes the bright colors to appear.  This doesn't work
  1104.     for background colors!  Without the '*' the bold attribute is removed.
  1105.     If you want to set the bold attribute in a different way, put a
  1106.     "cterm=" argument AFTER the "ctermfg=" or "cterbg=" argument.  Or use
  1107.     a number instead of a color name.
  1108.  
  1109.     The case of the color names is ignored.
  1110.  
  1111.     Note that for some color terminals these names may result in the wrong
  1112.     colors!
  1113.  
  1114.     When setting the "ctermfg" or "ctermbg" colors for the Normal group,
  1115.     these will become the colors used for the non-highlighted text.
  1116.     When setting the "ctermbg" color for the Normal group, the
  1117.     'background' option will be adjusted automatically.  This causes the
  1118.     highlight groups that depend on 'background' to change!  This means
  1119.     you should set the colors for Normal first, before setting other
  1120.     colors.
  1121.  
  1122.     When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
  1123.     needs to reset the color when exiting.  This is done with the "op"
  1124.     termcap entry |t_op|.  If this doesn't work correctly, try setting the
  1125.     't_op' option in your .vimrc.
  1126.  
  1127.  
  1128. 3. highlight arguments for the GUI
  1129.  
  1130. gui={attr-list}                        *highlight-gui*
  1131.     These give the attributes to use in the GUI mode.
  1132.     See |attr-list| for a description.
  1133.     Note that "bold" can be used here and by using a bold font.  They
  1134.     have the same effect.
  1135.  
  1136. font={font-name}                    *highlight-font*
  1137.     font-name is the name of a font, as it is used on the system Vim
  1138.     runs on.  For X11 this is a complicated name, for example:
  1139. >  font=-misc-fixed-bold-r-normal--14-130-75-75-c-70-iso8859-1
  1140.  
  1141.     The font-name "NONE" can be used to revert to the default font.
  1142.     When setting the font for the "Normal" group, this becomes the default
  1143.     font (until the 'guifont' option is changed; the last one set is
  1144.     used).  All fonts used should be of the same character size as the
  1145.     default font!  Otherwise redrawing problems will occur.
  1146.  
  1147. guifg={color-name}                    *highlight-guifg*
  1148. guibg={color-name}                    *highlight-guibg*
  1149.     These give the foreground (guifg) and background (guibg) color to
  1150.     use in the GUI.  There are a few special names:
  1151.         NONE        no color (transparant)
  1152.         bg        use normal background color
  1153.         background    use normal background color
  1154.         fg        use normal foreground color
  1155.         foreground    use normal foreground color
  1156.     To use a color name with an embedded space or other special character,
  1157.     put it in single quotes.  The single quote cannot be used then.
  1158.     Example:
  1159. >        :hi comment guifg='salmon pink'
  1160.  
  1161.                             *gui-colors*
  1162.     Suggested color names (these are available on most systems):
  1163.         Red        LightRed    DarkRed
  1164.         Green    LightGreen    DarkGreen    SeaGreen
  1165.         Blue    LightBlue    DarkBlue    SlateBlue
  1166.         Cyan    LightCyan    DarkCyan
  1167.         Magenta    LightMagenta    DarkMagenta
  1168.         Yellow    LightYellow    Brown
  1169.         Gray    LightGray    DarkGray
  1170.         Black    White
  1171.         Orange    Purple        Violet
  1172.  
  1173.     In the Win32 GUI version, additional system colors are available.  See
  1174.     |win32-colors|.
  1175.  
  1176.     You can also specify a color by its Red, Green and Blue values.
  1177.     The format is "#rrggbb", where
  1178.         "rr"    is the Red value
  1179.         "bb"    is the Blue value
  1180.         "gg"    is the Green value
  1181.     All values are hexadecimal, range from "00" to "ff".  Examples:
  1182. >  :highlight Comment guifg=#11f0c3 guibg=#ff00ff
  1183.  
  1184.                             *highlight-default*
  1185. These are the default highlighting groups.  These groups are used by the
  1186. 'highlight' option default.  See |'highlight'| for where each group is used.
  1187.     Cursor    guibg=Green                    *hl-Cursor*
  1188.             Highlighting for the character under the cursor.
  1189.     Directory   term=bold ctermfg=Blue guifg=Blue        *hl-Directory*
  1190.     IncSearch   links to |hl-Visual|                    *hl-IncSearch*
  1191.     ModeMsg    term=bold cterm=bold gui=bold            *hl-ModeMsg*
  1192.                                 *hl-MoreMsg*
  1193.     MoreMsg    term=bold cterm=bold ctermfg=Green gui=bold guifg=Green
  1194.                                 *hl-Question*
  1195.     Question    term=standout cterm=bold ctermfg=Green gui=bold guifg=Green
  1196.     SpecialKey  term=bold ctermfg=Blue guifg=Blue        *hl-SpecialKey*
  1197.     StatusLine  term=reverse cterm=reverse gui=reverse        *hl-StatusLine*
  1198.                                 *hl-Title*
  1199.     Title    term=bold cterm=bold ctermfg=Blue gui=bold guifg=Blue
  1200.     Visual    term=reverse cterm=reverse gui=reverse        *hl-Visual*
  1201.     WarningMsg  term=standout ctermfg=Red guifg=Red        *hl-WarningMsg*
  1202.     NonText    term=bold cterm=bold gui=bold guifg=Blue    *hl-NonText*
  1203.  
  1204. When 'background' is set to "light", these groups are used additionally:
  1205.     Normal    term=NONE cterm=NONE gui=NONE            *hl-Normal*
  1206.             Highlighting for the normal text.
  1207.     LineNr    term=underline ctermfg=Brown guifg=Brown    *hl-LineNr*
  1208.     ErrorMsg    term=standout ctermbg=LightRed guibg=Orange *hl-ErrorMsg*
  1209.     Search    term=reverse ctermbg=Yellow guibg=Yellow    *hl-Search*
  1210.  
  1211. When 'background' is set to "dark", these groups are used additionally:
  1212.     Normal    term=NONE cterm=NONE guibg=Black guifg=White *hl-Normal-dark*
  1213.     LineNr    term=underline ctermfg=Yellow guifg=Yellow   *hl-LineNr-dark*
  1214.     ErrorMsg    term=standout ctermbg=LightRed ctermfg=Black
  1215.                     guibg=Orange guifg=Black    *hl-ErrorMsg-dark*
  1216.     Search    term=reverse ctermbg=Yellow ctermfg=Yellow
  1217.                     guibg=Yellow guifg=Black    *hl-Search-dark*
  1218.  
  1219. For the GUI you can use these groups to set the colors for the menu and
  1220. scrollbars.  They don't have defaults.  This doesn't work for the Win32 GUI.
  1221.     Menu                            *hl-Menu*
  1222.     Scrollbar                            *hl-Scrollbar*
  1223.  
  1224. ==============================================================================
  1225. 10. Linking groups                    *:highlight-link*
  1226.  
  1227. When you want to use the same highlighting for several syntax groups, you
  1228. can do this more easily by linking the groups into one common highlight
  1229. group, and give the color attributes only for that group.
  1230.  
  1231.     :highlight[!] link {from-group} {to-group}
  1232.  
  1233. Notes:
  1234. - If the {from-group} and/or {to-group} doesn't exist, it is created.  You
  1235.   don't get an error message for a non-existing group.
  1236. - If the {to-group} is "NONE", the link is removed from the {from-group}.
  1237. - As soon as you use a ":highlight" command for a linked group, the link is
  1238.   removed.
  1239. - If there are already highlight settings for the {from-group}, the link is
  1240.   not made, unless the '!' is given.  For a ":highlight link" command in a
  1241.   sourced file, you don't get an error message.  This can be used to skip
  1242.   links for groups that already have settings.
  1243.  
  1244. ==============================================================================
  1245. 11. Cleaning up                        *:syn-clear*
  1246.  
  1247. If you want to clear the syntax stuff for the current buffer, you can use this
  1248. command:
  1249. >  :syntax clear
  1250.  
  1251. This command should be used when you want to switch off syntax highlighting,
  1252. or when you want to switch to using another syntax.  It's a good idea to
  1253. include this command at the beginning of a syntax file.
  1254.  
  1255. If you want to disable syntax highlighting for all buffers, you need to remove
  1256. the autocommands that load the syntax files:
  1257. >  :syntax off
  1258.  
  1259. What this command actually does, is executing the command
  1260. >  source $VIM/syntax/nosyntax.vim
  1261. See the "nosyntax.vim" file for details.  Note that for this to work $VIM must
  1262. be valid.  See |$VIM|.
  1263.  
  1264. To clean up specific syntax groups for the current buffer:
  1265. >  :syntax clear {group-name} ..
  1266. This removes all patterns and keywords for {group-name}.
  1267.  
  1268. ==============================================================================
  1269. 12. Highlighting tags                    *tag-highlight*
  1270.  
  1271. If you want to highlight all the tags in your file, you can use the following
  1272. mappings.
  1273.  
  1274.     <F11>    -- Generate tags.vim file, and highlight tags.
  1275.     <F12>    -- Just highlight tags based on existing tags.vim file.
  1276.  
  1277. >  map <F11>  :sp tags<CR>:%s/^\([^     :]*:\)\=\([^     ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
  1278. >  map <F12>  :so tags.vim<CR>
  1279.  
  1280. WARNING: The longer the tags file, the slower this will be, and the more
  1281. memory Vim will consume.
  1282.  
  1283. Only highlighting typedefs, unions and structs can be done too.  For this you
  1284. must use Exhuberant ctags (included with Vim).
  1285.  
  1286. Put these lines in your Makefile:
  1287.  
  1288. # Make a highlight file for types.  Requires Exhuberant ctags and awk
  1289. types: types.vim
  1290. types.vim: *.[ch]
  1291.     ctags -i=gstuS -o- *.[ch] |\
  1292.         awk 'BEGIN{printf("syntax keyword Type\t")}\
  1293.             {printf("%s ", $$1)}END{print ""}' > $@
  1294.  
  1295. And put these lines in your .vimrc:
  1296.  
  1297. >  " load the types.vim highlighting file, if it exists
  1298. >  autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
  1299. >  autocmd BufRead,BufNewFile *.[ch] if file_readable(fname)
  1300. >  autocmd BufRead,BufNewFile *.[ch]   exe 'so ' . fname
  1301. >  autocmd BufRead,BufNewFile *.[ch] endif
  1302.  
  1303. ==============================================================================
  1304. 13. Color xterms                *xterm-color* *color-xterm*
  1305.  
  1306. Most color xterms have only eight colors.  They should work with these
  1307. settings for without |+terminfo|:
  1308. >  :set t_Co=8
  1309. >  :set t_Sf=<Esc>[3%dm
  1310. >  :set t_Sb=<Esc>[4%dm
  1311. And with |+terminfo|:
  1312. >  :set t_Co=8
  1313. >  :set t_Sf=<Esc>[3%p1%dm
  1314. >  :set t_Sb=<Esc>[4%p1%dm
  1315.     [<Esc> is a real escape, type CTRL-V <Esc>]
  1316.  
  1317. To test your color setup, a file has been included in the Vim distribution.
  1318. To use it, execute these commands:
  1319. >  :e $VIM/syntax/colortest.vim
  1320. >  :so %
  1321.  
  1322. Some versions of xterm (and other terminals, like the linux console) can
  1323. output lighter foreground colors, even though the number of colors is defined
  1324. at 8.  Therefore Vim sets the "cterm=bold" attribute for light foreground
  1325. colors, when 't_Co' is 8.
  1326.  
  1327. To get 16 colors, get the newest xterm version (which should be included with
  1328. Xfree86 3.3).  You can also find the latest version at:
  1329.     http://www.clark.net/pub/dickey/xterm
  1330. You probably have to enable 16 colors when running configure:
  1331.     ./configure --disable-bold-color
  1332. If you only get 8 colors, check the xterm compilation settings.
  1333.  
  1334. This xterm should work with these settings without |+terminfo|:
  1335. >  :set t_Co=16
  1336. >  :set t_Sf=<Esc>[3%dm
  1337. >  :set t_Sb=<Esc>[4%dm
  1338. Vim will recognize these settings, and automatically translate cterm colors of
  1339. 8 and above to "<Esc>[9%dm" and "<Esc>[10%dm".
  1340.  
  1341. When the |+terminfo| feature is used, these settings should work:
  1342. >  :set t_Co=16
  1343. >  :set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
  1344. >  :set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
  1345.     [<Esc> is a real escape, type CTRL-V <Esc>]
  1346.  
  1347. Or just set the TERM environment variable to "xterm-16color" and try if that
  1348. works.
  1349.  
  1350. You probably want to use these X resouces (put them in your ~/.Xdefaults file):
  1351.     XTerm*color0:            #000000
  1352.     XTerm*color1:            #c00000
  1353.     XTerm*color2:            #008000
  1354.     XTerm*color3:            #808000
  1355.     XTerm*color4:            #0000c0
  1356.     XTerm*color5:            #c000c0
  1357.     XTerm*color6:            #008080
  1358.     XTerm*color7:            #c0c0c0
  1359.     XTerm*color8:            #808080
  1360.     XTerm*color9:            #ff6060
  1361.     XTerm*color10:            #00ff00
  1362.     XTerm*color11:            #ffff00
  1363.     XTerm*color12:            #8080ff
  1364.     XTerm*color13:            #ff40ff
  1365.     XTerm*color14:            #00ffff
  1366.     XTerm*color15:            #ffffff
  1367.     Xterm*cursorColor:        Black
  1368.  
  1369. [Note: The cursorColor is required to work around a bug, which changes the
  1370. cursor color to the color of the last drawn text.  This has been fixed by a
  1371. newer version of xterm, but not everybody is using yet]
  1372.  
  1373. To get these right away, reload the .Xdefaults file to the X Option database
  1374. Manager (you only need to do this when you just changed the .Xdefaults file):
  1375. >  xrdb -merge ~/.Xdefaults
  1376.  
  1377.  vim:tw=78:ts=8:sw=4
  1378.